/*
 * @Author: sonss
 * @Date: 2024-08-20 18:00:58
 * @LastEditTime: 2024-08-22 12:10:53
 * @FilePath: /ss-file-antd/src/utils/storage.ts
 * @Description:  缓存
 */

// 写入
const setStorage = (key: string, value: any) => {
   const data = JSON.stringify(value);
   localStorage.setItem(key, data);
}

// 读取
const getStorage = (key: string): any => {
    const data = localStorage.getItem(key);
    if (data === '' || data === null) {
        return undefined;
    }
    return JSON.parse(data);
}

// 清除
const clearStorage = (key: string): any => {
    localStorage.removeItem(key);
}

export {
    setStorage, getStorage, clearStorage
}